package com.arrays;

public class ValidPerfectSquare0123_367 {
    public boolean isPerfectSquare(int num) {
        if(num == 1) return true;
        long left = 0, right=num/2,mid,mul;
        while (left<=right){
            mid = (left+right) >> 1;
            mul = mid * mid;
            if(mul == num) return true;
            if(mul > num) right = mid -1;
            if(mul < num) left = mid +1;
        }
        return false;
    }
}
